# coding=utf-8
# 本题为考试多行输入输出规范示例，无需提交，不计分。
import sys


def pointNum(info):
    x = abs(info[0])
    y = abs(info[1])
    radius = abs(info[2])

    count = 0
    if x < radius:
        count += 2
    elif x == radius:
        count += 1
    else:
        count += 0

    if y < radius:
        count += 2
    elif y == radius:
        count += 1
    else:
        count += 0

    if x*x + y*y == radius*radius:
        count -= 1
    return count


if __name__ == "__main__":
    # 读取第一行的n
    n = int(sys.stdin.readline().strip())
    res = []
    for i in range(n):
        # 读取每一行
        line = sys.stdin.readline().strip()
        # 把每一行的数字分隔后转化成int列表
        value = list(map(int, line.split()))
        res.append(pointNum(value))
    print(res)
